﻿using System;

namespace Neovolve.Extensibility.VisualStudio.ReflectorLink
{
    /// <summary>
    /// The <see cref="LaunchAction"/>
    /// class describes that action that needs to be taken when launching Reflector.
    /// </summary>
    internal class LaunchAction
    {
        /// <summary>
        /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>.</param>
        /// <returns>
        /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
        /// </returns>
        /// <exception cref="T:System.NullReferenceException">The <paramref name="obj"/> parameter is null.</exception>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return false;
            }

            if (ReferenceEquals(this, obj))
            {
                return true;
            }

            if (GetHashCode()
                == obj.GetHashCode())
            {
                return true;
            }

            return base.Equals(obj);
        }

        /// <summary>
        /// Serves as a hash function for a particular type.
        /// </summary>
        /// <returns>
        /// A hash code for the current <see cref="T:System.Object"/>.
        /// </returns>
        public override int GetHashCode()
        {
            return ToString().GetHashCode();
        }

        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        public override string ToString()
        {
            const String Separator = " - ";

            return ActionType + Separator + AssemblyPath;
        }

        /// <summary>
        /// Gets or sets the type of the action.
        /// </summary>
        /// <value>The type of the action.</value>
        public LaunchActionType ActionType
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the assembly path.
        /// </summary>
        /// <value>The assembly path.</value>
        public String AssemblyPath
        {
            get;
            set;
        }

        /// <summary>
        /// Gets the default action.
        /// </summary>
        /// <value>The default action.</value>
        public static LaunchAction Default
        {
            get
            {
                return new LaunchAction();
            }
        }
    }
}